<?php

namespace component\system\system_user;

use think\Validate;

class SystemUserValidate extends Validate
{
    protected $rule = [
        'username' => 'require|length:1,30',
        'password' => 'require|alphaDash|length:6,18',
        'confirm' => 'require|confirm:password',
        'nickname' => 'length:1,30',
        'avatar' => 'length:1,255',
        'email' => 'email|length:1,50',
        'status' => 'integer|in:0,1',
    ];

    protected $message = [
        'username.require' => '请输入用户名',
        'username.length' => '用户名长度不正确,允许的长度1~30',
        'password.require' => '请输入密码',
        'password.alphaDash' => '密码值为字母、数字、下划线的组合',
        'password.length' => '密码长度不正确,允许的长度6~18',
        'confirm.require' => '请输入密码',
        'confirm.confirm' => '密码密码跟确认密码不一致',
        'nickname.length' => '昵称长度不正确,允许的长度1~30',
        'avatar.length' => '头像长度不正确,允许的长度1~255',
        'email.email' => '邮箱地址格式错误',
        'email.length' => '邮箱地址长度不正确,允许的长度1~50',
        'status.integer' => '状态格式错误',
        'status.in' => '状态可选值错误',
    ];

    protected $scene = [

        'put' => [
            'nickname',
            'phone',
            'email',
        ],

        'patch' => [
            'status' => 'in',
        ],

        'setPassword' => [
            'password',
            'confirm'
        ]
    ];
}